﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using GCELibrary.Current;
namespace ZF.WS.test
{
    public partial class tolc : BLL.Page.GMPage
    {
        /// <summary>
        /// 报告生成器
        /// </summary>
        public override WarnFactory WarnFactory { get { return new WarnFactory("/warn.aspx"); } }
        public int InteSet { get; set; }
        public string RoomKey { get; set; }
        [PageArgument(Key = "id", CanNull = false)]
        /// <summary>
        /// 连接人的Id
        /// </summary>
        public int ExpertId { get; set; }

    


        public ZF.BLL.GeneralMember _member = null;

        public Model.US_Member Expert { get; set; }
      
 
        protected void Page_Load(object sender, EventArgs e)
        {
            BLL.OnLine.Reg(this.CurrentUser);
            using (var dc = SiteInfo.CreateDBDataContext())
            {
                Expert = dc.US_Member.FirstOrDefault(p => p.MemberId == ExpertId && p.IsExpert);
                if (Expert == null)
                {
                    throw WarnFactory.CreateWarn(WarnCode.ReocrdNoFind);
                }
            }
            try
            {
               var cr = BLL.Chat.Call(this.CurrentUser, ExpertId);
               RoomKey = cr.Key;
               InteSet = cr.InteSet;
            }
            catch (Exception ex)
            {

                WarnFactory.CreateWarn(new PageWarnParameter()
                {
                    JscriptMode = true,
                    Message = ex.Message,
                    Link = WarnLink.Close,
                }).Alert();
            }
        }
    }
}
